package chen.web.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import chen.web.user.NoPermissionException;

@Controller
public class ExceptionController {
	
	  @ExceptionHandler(IOException.class)
	  public String handleIOException(IOException e) {
		  return ClassUtils.getShortName(e.getClass());
	  }
	  
	  @ExceptionHandler(NoPermissionException.class)
	  public String handleNoPermissionException(NoPermissionException e) {
		  return ClassUtils.getShortName(e.getClass());
	  }
	  
	  @ExceptionHandler(ResourceNotFoundException.class)
	  public String handleResourceNotFoundException(ResourceNotFoundException e, HttpServletResponse response) {
		  return ClassUtils.getShortName(e.getClass());
	  }
	  
	  @ExceptionHandler(IllegalArgumentException.class)
	  public String handleIllegalArgumentException(NoPermissionException e) {
		  return ClassUtils.getShortName(e.getClass());
	  }
}
